package eerbaar.v2.effects.internal;

import java.util.Date;

public class GrowingForce extends Force {

    private final long startTime;
    private int finalAge = 7000;

    public GrowingForce(double x, double y, int finalAge) {
        super(x, y);
        this.startTime = new Date().getTime();
        this.finalAge = finalAge;
    }

    @Override
    public double getX() {
        double result = super.getX();
        return scale(result);
    }

    @Override
    public double getY() {
        double result = super.getY();
        return scale(result);
    }

    private double scale(double result) {
        int age = (int) (new Date().getTime() - startTime);
        double normalAge = ((double) age) / ((double) finalAge);
        double scaledAge = (10 * normalAge) + 1;
        double factor = scaledAge;
        result *= factor;
        return result;
    }

}